

from rest_framework import serializers
from goods.models import GoodsVisitCount

class GoodsVisitCountModelSerializer(serializers.ModelSerializer):
    # category默认映射类型序列化结果是主键值
    # 注意：在模型类序列化器中，我们通过重写类属性覆盖原有映射
    category = serializers.StringRelatedField()

    class Meta:
        model = GoodsVisitCount
        fields = ['count', 'category']